package com.beiding.jsonanalyzer.analyze.query;

/**
 * 连接词语法
 *
 * @author 丁常磊
 * @date 2022/6/27 11:41
 */

public interface ConnectGrammar extends ContextGenerate {

    /**
     * 添加and连接符
     *
     * @return
     */
    default ConnectOperator and() {
        return new ConnectOperator(getQueryBuilder().addElement(Connector.AND));
    }

    /**
     * 添加or连接符
     *
     * @return
     */
    default ConnectOperator or() {
        return new ConnectOperator(getQueryBuilder().addElement(Connector.OR));
    }

    /**
     * 添加and连接符,放入子条件
     *
     * @param comparator
     * @return
     */
    default LastConnectOperator and(ContextGenerate comparator) {
        return new LastConnectOperator(getQueryBuilder().addElement(Connector.AND).addElement(comparator.getQueryBuilder()));
    }

    /**
     * 添加or连接符并放入子条件
     *
     * @param comparator
     * @return
     */
    default LastConnectOperator or(ContextGenerate comparator) {
        return new LastConnectOperator(getQueryBuilder().addElement(Connector.OR).addElement(comparator.getQueryBuilder()));
    }


}
